package com.xunk.equipment.service.acrel.constant;

import org.apache.commons.collections4.map.CaseInsensitiveMap;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @ProjectName: xunk
 * @Package: com.xunk.equipment.service.acrel.constant
 * @ClassName: ArcelEquipmentTypeConstant
 * @Author: dongxiaoxin
 * @Description: 安科瑞设备类型
 * @Date: 2021/3/30 9:17
 * @Version: 1.0
 */
public enum AcrelEquipmentTypeEnum {

    WATER("水表","acrel-water-meter"),

    HEAT("热量表","acrel-heat-meter");

    /**
     *  设备名称
     */
    String equiqmentName;
    /**
     *  对应的beanName
     */
    String beanName;

    AcrelEquipmentTypeEnum(String equiqmentName, String beanName){
        this.equiqmentName = equiqmentName;
        this.beanName = beanName;
    }

    private static final Map<String, AcrelEquipmentTypeEnum> ARCEL_EQUIPMENT_BEAN_MAP = Arrays.stream(AcrelEquipmentTypeEnum.values()).collect(Collectors.toMap(AcrelEquipmentTypeEnum::getEquiqmentName, Function.identity(), (a, b) -> a, CaseInsensitiveMap::new));

    public static AcrelEquipmentTypeEnum getEquipmentBeanName(String equiqmentName) {
        return ARCEL_EQUIPMENT_BEAN_MAP.getOrDefault(equiqmentName, WATER);
    }

    public String getEquiqmentName() {
        return equiqmentName;
    }

    public void setEquiqmentName(String equiqmentName) {
        this.equiqmentName = equiqmentName;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }
}
